#!/bin/bash

SCRIPT_DIR=$(cd `dirname $0` && pwd)
cd $SCRIPT_DIR

rm -rf ./_install

cd pure-ftpd || exit 1
git reset --hard || exit 1

cd ..
patch -p0 < ftpd.patch
cd pure-ftpd

./autogen.sh || exit 1

./configure CC=arm-openwrt-linux-gcc \
    --prefix=$SCRIPT_DIR/_install \
    CFLAGS="-Os -mcpu=cortex-a7 -mfpu=neon-vfpv4 -I/opt/yi/toolchain-sunxi-musl/toolchain/include -L/opt/yi/toolchain-sunxi-musl/toolchain/lib" \
    AR=arm-openwrt-linux-ar \
    RANLIB=arm-openwrt-linux-ranlib \
    --host=arm \
    --with-minimal \
    || exit 1
